package logic;

import java.security.InvalidParameterException;

public class Card {
	private final static String RANKS = new String("23456789DJQKA");
	private final static String SUITS = new String("COPE");
	
	private int rank;
	private int suit;
	private String name;
	
	public Card(String card) {
		name = card;
		rank = RANKS.indexOf(card.substring(0,1)) + 2;
		suit = SUITS.indexOf(card.substring(1,2));
		if((rank == 1) || (suit == -1)){
			throw new InvalidParameterException();
		}
	}
	
	public int getRank() {
		return rank;
	}

	public char getSuit() {
		return SUITS.charAt(suit);
	}
	
	@Override
	public boolean equals(Object o) {
		Card c = (Card) o;
		
		if(this.getRank() == c.getRank()) {
			if(this.getSuit() == c.getSuit()) {
				return true;
			}
		}
		
		return false;
	}

	public String getName() {
		return name;
		
	}
}
